from rest_framework import serializers

from coder.models import Project, UserDefinedBlocklyBlock, CodeTemplate


class BlocklyCodeSerializer(serializers.ModelSerializer):
    """
        Blockly项目代码序列化器
    """
    object_code_language = serializers.CharField(read_only=True, source='get_object_code_language_display')

    class Meta:
        model = Project
        fields = '__all__'


class BlocklyFunctionCodeSerializer(serializers.ModelSerializer):
    """
        Blockly自定义函数序列化器
    """

    class Meta:
        model = UserDefinedBlocklyBlock
        fields = '__all__'


class GenerateTemplateSerializer(serializers.ModelSerializer):
    """
        代码模板
    """

    class Meta:
        model = CodeTemplate
        fields = '__all__'
